package com.wang.controller;

import com.wang.pojo.TbTopic;
import com.wang.pojo.TbTopicSimply;
import com.wang.pojo.TbUserAnswer;
import com.wang.service.TbTopicService;
import com.wang.utills.R;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;

import javax.annotation.Resource;

@RequestMapping("/review/topic")
@RestController
public class TbreviewController {

    /*
    * 题目
    * */
    @Resource
    private TbTopicService tbTopicService;




    /*
    * 添加新的题目
    *
    * */
    @RequestMapping("/addnewtopic")
    public R  addnewtopic(@RequestBody TbTopic tbTopic){
      return   this.tbTopicService.addnewtopic(tbTopic);

    }

    /*
    * 删除题目
    * */
    @RequestMapping("/delbuytid")
    public R delbuytid(Integer  tid){
        return  this.tbTopicService.delbuytid(tid);
    }

    /*
     * 删除题目
     * */
    @RequestMapping("/upbuytid")
    public R upbuytid(@RequestBody TbTopic tbTopic ){
        return  this.tbTopicService.upbuytid(tbTopic);
    }

    //-----------------------------------------------------------------------

    /*
    * 简单问卷的list
    * */
    @RequestMapping("findtopicsimplybyall")
    public  R findtopicsimplyall(){
        return  this.tbTopicService.findtopicsimplyall();
    }

    /*
     * 简单问卷的添加
     * */
    @RequestMapping("addtopicsimply")
    public  R addtopicsimply(@RequestBody TbTopicSimply tbTopicSimply){
        return  this.tbTopicService.addtopicsimply(tbTopicSimply);
    }

    /*
     * 简单问卷的删除
     * */
    @RequestMapping("deltopicsimply")
    public  R deltopicsimply(Integer qid){
        return  this.tbTopicService.deltopicsimply(qid);
    }

    /*
    * 综合问卷的list
    * */
    @RequestMapping("findtopicall")
    public  R findtopicall(){
        return this.tbTopicService.findTopicAll();
    }

    /*
    * 答卷
    * */
    @RequestMapping("addtopicanswer")
    public R addtopicanswer(@RequestBody TbUserAnswer tbUserAnswer){
        return this.tbTopicService.addtopicanswer(tbUserAnswer);
    }


    /*
    * 生成信息
    * */
    @RequestMapping("addreport")
    public R addreport(ServerWebExchange exchange){
        String toukes = exchange.getRequest().getHeaders().getFirst("toukes");

        return this.tbTopicService.addreport(toukes);
    }




}
